Skip to content

[Feat] Add Lasso Guardrail to LiteLLM #11565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 10, 2025
Merged

[Feat] Add Lasso Guardrail to LiteLLM #11565

merged 5 commits into from
Jun 10, 2025

Conversation

ishaan-jaff
Copy link
Contributor

@ishaan-jaff ishaan-jaff commented Jun 9, 2025

[Feat] Add Lasso Guardrail to LiteLLM

Adds initial support for the Lasso Security guardrail into LiteLLM, complete with first‐party integration code, tests, and documentation.

  • first version of lasso guardrail in litellm

  • update to the new Lasso API

  • change prod api_base and kill the request when lasso detect issue.

  • change test for now api, local test pass

  • add async tests

  • all tests pass

  • add docs for the new lasso guardrail

  • Remove support for modes other than pre_call in Lasso guardrail

  • code structure and naming

  • only pre_call docs

  • fix lint errors

  • move test to the new location follows the same directory structure as litellm/.

Title

Relevant issues

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🆕 New Feature
✅ Test

Changes

* first version of lasso guardrail in litellm

* update to the new Lasso API

* change  prod api_base and kill the request when lasso detect issue.

* change test for now api, local test pass

* add async tests

* all tests pass

* add docs for the new lasso guardrail

* Remove support for modes other than pre_call in Lasso guardrail

* code structure and naming

* only pre_call docs

* fix lint errors

* move test to the new location  follows the same directory structure as litellm/.
Copy link

vercel bot commented Jun 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 10, 2025 1:43am

@CLAassistant
Copy link

CLAassistant commented Jun 9, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ ishaan-jaff
❌ oroxenberg
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds initial support for the Lasso Security guardrail into LiteLLM, complete with first‐party integration code, tests, and documentation.

  • Introduce LassoGuardrail hook, registry, and initializer
  • Add async and sync tests for Lasso pre‐call guardrail behavior
  • Update docs and sidebar for Lasso guardrail and add model backup entry

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/litellm/proxy/guardrails/guardrail_hooks/test_lasso.py New unit tests for async and sync pre‐call logic
tests/guardrails_tests/test_lasso_guardrails.py Duplicate of above tests in alternate folder
litellm/types/guardrails.py Add LASSO to supported integrations enum
litellm/proxy/guardrails/guardrail_registry.py Register initialize_lasso in the registry
litellm/proxy/guardrails/guardrail_initializers.py Implement initialize_lasso initializer
litellm/proxy/guardrails/guardrail_hooks/lasso.py Core LassoGuardrail implementation
docs/my-website/sidebars.js Include Lasso guardrail in sidebar navigation
docs/my-website/docs/proxy/guardrails/lasso_security.md Detailed Quick Start and examples for Lasso
Comments suppressed due to low confidence (4)

tests/guardrails_tests/test_lasso_guardrails.py:1

  • [nitpick] These tests largely duplicate those in tests/litellm/proxy/guardrails/guardrail_hooks/test_lasso.py. Consider consolidating or removing one copy to avoid redundancy.
import os

tests/litellm/proxy/guardrails/guardrail_hooks/test_lasso.py:34

  • This test only ensures that initialization does not error, but does not assert that the LassoGuardrail callback was actually registered. Add an assertion to verify the callback is present in litellm.callbacks.
def test_lasso_guard_config():

docs/my-website/docs/proxy/guardrails/lasso_security.md:26

  • The Quick Start YAML example omits default_on: true, which is required by the initializer. Add default_on: true under the litellm_params block for consistency.
      mode: "pre_call"

docs/my-website/docs/proxy/guardrails/lasso_security.md:90

  • The example curl in the docs calls https://server.lasso.security/gateway/v1/chat, but the default api_base in code is .../gateway/v2/classify. Update the docs to reference the correct endpoint or note the version difference.
    "guardrails": ["lasso-guard"]

@@ -187,3 +188,26 @@ def initialize_pangea(litellm_params, guardrail):
litellm.logging_callback_manager.add_litellm_callback(_pangea_callback)

return _pangea_callback


def initialize_lasso(litellm_params, guardrail):
Copy link
Preview

Copilot AI Jun 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initialize_lasso function registers the callback but doesn’t return it. To match other initializers and ensure callers receive the created LassoGuardrail instance, add return _lasso_callback at the end of the if block.

Copilot uses AI. Check for mistakes.

@ishaan-jaff ishaan-jaff merged commit c6d0878 into main Jun 10, 2025
27 of 46 checks passed
stefan-- pushed a commit to stefan--/litellm that referenced this pull request Jun 12, 2025
* Feature/lasso guardrail (BerriAI#9002)

* first version of lasso guardrail in litellm

* update to the new Lasso API

* change  prod api_base and kill the request when lasso detect issue.

* change test for now api, local test pass

* add async tests

* all tests pass

* add docs for the new lasso guardrail

* Remove support for modes other than pre_call in Lasso guardrail

* code structure and naming

* only pre_call docs

* fix lint errors

* move test to the new location  follows the same directory structure as litellm/.

* add lasso guard

* docs lasso docs

* add lasso guardrail

* fix lasso guardrail

---------

Co-authored-by: oroxenberg <oro@lasso.security>
X4tar pushed a commit to X4tar/litellm that referenced this pull request Jun 17, 2025
* Feature/lasso guardrail (BerriAI#9002)

* first version of lasso guardrail in litellm

* update to the new Lasso API

* change  prod api_base and kill the request when lasso detect issue.

* change test for now api, local test pass

* add async tests

* all tests pass

* add docs for the new lasso guardrail

* Remove support for modes other than pre_call in Lasso guardrail

* code structure and naming

* only pre_call docs

* fix lint errors

* move test to the new location  follows the same directory structure as litellm/.

* add lasso guard

* docs lasso docs

* add lasso guardrail

* fix lasso guardrail

---------

Co-authored-by: oroxenberg <oro@lasso.security>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants